clear
one_step=0;
near_var=0;
cmr=0;
jq=0;
mpt=0;
bcdz=0;
chol=0;
labor=1;
nonlin=0;
if labor==1&&one_step==0&&near_var==0&&bcdz==0&&jq==0&&cmr==0&&mpt==0&&chol==0&&nonlin==0
load results_replications_labor
end
if one_step==1
load results_replications_labor_one_step
% reg_firms1=reg_firms;
% load results_replications_labor_one_step2
% reg_firms2=reg_firms;
% load results_replications_labor_one_step3
% reg_firms3=reg_firms;
% load results_replications_labor_one_step4
% reg_firms4=reg_firms;
% load results_replications_labor_one_step5
% reg_firms5=reg_firms;
% load results_replications_labor_one_step6
% reg_firms6=reg_firms;
% reg_firms=[reg_firms1;reg_firms2;reg_firms3;reg_firms4;reg_firms5;reg_firms6];
% load data_cs_tfp_labor
% parfor i=1:500
% mis(:,:,i)=data3*reg_firms(:,:,i);
% end
end
if near_var==1
load results_replications_labor_near_var
end
if bcdz==1
load results_replications_labor_bcdz
end
if jq==1
load results_replications_labor_jq
end
if cmr==1
load results_replications_labor_cmr
end
if mpt==1
load results_replications_labor_mpt
end
if chol==1
load results_replications_labor_chol
end
if nonlin==1
load results_replications_labor_nonlin
end
clearvars -except reg_firms mis* labor one_step cmr near_var jq bcdz mpt chol nonlin 
if nonlin==0
m=quantile(reg_firms,[0.16,0.5,0.84],3);
m_mis=quantile(mis,[0.16,0.5,0.84],3);


irf_diff1=zeros(20,5,500);
for i=1:500
for j=1:5
    irf_diff1(:,j,i)=reg_firms(1,:,i)-reg_firms(j+1,:,i);
end
for j=[3:6]
    irf_diff2(:,j,i)=reg_firms(2,:,i)-reg_firms(j,:,i);
end
for j=[4:6]
    irf_diff3(:,j,i)=reg_firms(3,:,i)-reg_firms(j,:,i);
end
for j=[5:6]
    irf_diff4(:,j,i)=reg_firms(4,:,i)-reg_firms(j,:,i);
end
for j=[6:6]
    irf_diff5(:,j,i)=reg_firms(5,:,i)-reg_firms(j,:,i);
end
end
irf_diff11=quantile(irf_diff1,[0.16,0.5,0.84],3);
irf_diff22=quantile(irf_diff2,[0.16,0.5,0.84],3);
irf_diff33=quantile(irf_diff3,[0.16,0.5,0.84],3);
irf_diff44=quantile(irf_diff4,[0.16,0.5,0.84],3);
irf_diff55=quantile(irf_diff5,[0.16,0.5,0.84],3);


x=1:20;w(1)=100;i=1;s=12;title2{1}='Percentage Deviation';title22{1}='P.P Deviation';
           subplot(3,3,1),plot(x,w(i)*m(1,:,2),'b-',x,w(i)*m(1,:,1),'b--',x,w(i)*m(1,:,3),'b--','LineWidth',3);
title('0-4 Employees','fontsize',s,'Color', [0,0,0.005]); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,2),plot(x,w(i)*m(2,:,2),'b-',x,w(i)*m(2,:,1),'b--',x,w(i)*m(2,:,3),'b--','LineWidth',3);
title('5-9 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,3),plot(x,w(i)*m(3,:,2),'b-',x,w(i)*m(3,:,1),'b--',x,w(i)*m(3,:,3),'b--','LineWidth',3);
title('10-19 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,4),plot(x,w(i)*m(4,:,2),'b-',x,w(i)*m(4,:,1),'b--',x,w(i)*m(4,:,3),'b--','LineWidth',3);
title('20-99 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,5),plot(x,w(i)*m(5,:,2),'b-',x,w(i)*m(5,:,1),'b--',x,w(i)*m(5,:,3),'b--','LineWidth',3);
title('100-499 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,6),plot(x,w(i)*m(6,:,2),'b-',x,w(i)*m(6,:,1),'b--',x,w(i)*m(6,:,3),'b--','LineWidth',3);
title('500+ Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,7),plot(x,w(i)*m_mis(1,:,2),'b-',x,w(i)*m_mis(1,:,1),'b--',x,w(i)*m_mis(1,:,3),'b--','LineWidth',3);
title('Labor-Misallocation-Induced TFP Response','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])

set(gcf,'position',get(0,'screensize'))   
if labor==1&&one_step==0&&near_var==0&&bcdz==0&&jq==0&&cmr==0&&mpt==0&&chol==0&&nonlin==0
export_fig(sprintf('BZ_FIRM_ALL_LABOR%d.pdf',i),'-transparent');
end
if one_step==1
export_fig(sprintf('BZ_FIRM_ALL_LABOR_ONE_STEP%d.pdf',i),'-transparent');
end
if near_var==1
  export_fig(sprintf('BZ_FIRM_ALL_LABOR_NEAR_VAR%d.pdf',i),'-transparent');
end
if bcdz==1
  export_fig(sprintf('BZ_FIRM_ALL_LABOR_BCDZ%d.pdf',i),'-transparent');
end
if jq==1
  export_fig(sprintf('BZ_FIRM_ALL_LABOR_JQ%d.pdf',i),'-transparent');
end
if cmr==1
  export_fig(sprintf('BZ_FIRM_ALL_LABOR_CMR%d.pdf',i),'-transparent');
end
if mpt==1
  export_fig(sprintf('BZ_FIRM_ALL_LABOR_MPT%d.pdf',i),'-transparent');
end
if chol==1
  export_fig(sprintf('BZ_FIRM_ALL_LABOR_CHOL%d.pdf',i),'-transparent');
end
s=11;
  subplot(5,3,1),plot(x,w(i)*irf_diff11(:,1,2),'b-',x,w(i)*irf_diff11(:,1,1),'b--',x,w(i)*irf_diff11(:,1,3),'b--','LineWidth',3);
title('0-4 Minus 5-9','fontsize',s,'Color', [0,0,0.005]); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
  subplot(5,3,2),plot(x,w(i)*irf_diff11(:,2,2),'b-',x,w(i)*irf_diff11(:,2,1),'b--',x,w(i)*irf_diff11(:,2,3),'b--','LineWidth',3);
title('0-4 Minus 10-19','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,3),plot(x,w(i)*irf_diff11(:,3,2),'b-',x,w(i)*irf_diff11(:,3,1),'b--',x,w(i)*irf_diff11(:,3,3),'b--','LineWidth',3);
title('0-4 Minus 20-99','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,4),plot(x,w(i)*irf_diff11(:,4,2),'b-',x,w(i)*irf_diff11(:,4,1),'b--',x,w(i)*irf_diff11(:,4,3),'b--','LineWidth',3);
title('0-4 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,5),plot(x,w(i)*irf_diff11(:,5,2),'b-',x,w(i)*irf_diff11(:,5,1),'b--',x,w(i)*irf_diff11(:,5,3),'b--','LineWidth',3);
title('0-4 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,6),plot(x,w(i)*irf_diff22(:,3,2),'b-',x,w(i)*irf_diff22(:,3,1),'b--',x,w(i)*irf_diff22(:,3,3),'b--','LineWidth',3);
title('5-9 Minus 10-19','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,7),plot(x,w(i)*irf_diff22(:,4,2),'b-',x,w(i)*irf_diff22(:,4,1),'b--',x,w(i)*irf_diff22(:,4,3),'b--','LineWidth',3);
title('5-9 Minus 20-99','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,8),plot(x,w(i)*irf_diff22(:,5,2),'b-',x,w(i)*irf_diff22(:,5,1),'b--',x,w(i)*irf_diff22(:,5,3),'b--','LineWidth',3);
title('5-9 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,9),plot(x,w(i)*irf_diff22(:,6,2),'b-',x,w(i)*irf_diff22(:,6,1),'b--',x,w(i)*irf_diff22(:,6,3),'b--','LineWidth',3);
title('5-9 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,10),plot(x,w(i)*irf_diff33(:,4,2),'b-',x,w(i)*irf_diff33(:,4,1),'b--',x,w(i)*irf_diff33(:,4,3),'b--','LineWidth',3);
title('10-19 Minus 20-99','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,11),plot(x,w(i)*irf_diff33(:,5,2),'b-',x,w(i)*irf_diff33(:,5,1),'b--',x,w(i)*irf_diff33(:,5,3),'b--','LineWidth',3);
title('10-19 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,12),plot(x,w(i)*irf_diff33(:,6,2),'b-',x,w(i)*irf_diff33(:,6,1),'b--',x,w(i)*irf_diff33(:,6,3),'b--','LineWidth',3);
title('10-19 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,13),plot(x,w(i)*irf_diff44(:,5,2),'b-',x,w(i)*irf_diff44(:,5,1),'b--',x,w(i)*irf_diff44(:,5,3),'b--','LineWidth',3);
title('20-99 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,14),plot(x,w(i)*irf_diff44(:,6,2),'b-',x,w(i)*irf_diff44(:,6,1),'b--',x,w(i)*irf_diff44(:,6,3),'b--','LineWidth',3);
title('20-99 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,15),plot(x,w(i)*irf_diff55(:,6,2),'b-',x,w(i)*irf_diff55(:,6,1),'b--',x,w(i)*irf_diff55(:,6,3),'b--','LineWidth',3);
title('100-499 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])

set(gcf,'position',get(0,'screensize'))   
if labor==1&&one_step==0&&near_var==0&&bcdz==0&&jq==0&&cmr==0&&mpt==0&&chol==0
export_fig(sprintf('BZ_FIRM_DIST_LABOR%d.pdf',i),'-transparent');
end
if one_step==1
export_fig(sprintf('BZ_FIRM_DIST_LABOR_ONE_STEP%d.pdf',i),'-transparent');
end
if near_var==1
export_fig(sprintf('BZ_FIRM_DIST_LABOR_NEAR_VAR%d.pdf',i),'-transparent');
end
if bcdz==1
export_fig(sprintf('BZ_FIRM_DIST_LABOR_BCDZ%d.pdf',i),'-transparent');
end
if jq==1
export_fig(sprintf('BZ_FIRM_DIST_LABOR_JQ%d.pdf',i),'-transparent');
end
if cmr==1
export_fig(sprintf('BZ_FIRM_DIST_LABOR_CMR%d.pdf',i),'-transparent');
end
if mpt==1
export_fig(sprintf('BZ_FIRM_DIST_LABOR_MPT%d.pdf',i),'-transparent');
end
if chol==1
export_fig(sprintf('BZ_FIRM_DIST_LABOR_CHOL%d.pdf',i),'-transparent');
end
close all
if labor==1&&one_step==0&&near_var==0&&bcdz==0&&jq==0&&cmr==0&&mpt==0&&chol==0
save('labor_QUARTERLY_RESULTS_LABOR');
end
if one_step==1
save('labor_QUARTERLY_RESULTS_LABOR_ONE_STEP');
end
if near_var==1
save('labor_QUARTERLY_RESULTS_LABOR_NEAR_VAR');
end
if bcdz==1
save('labor_QUARTERLY_RESULTS_LABOR_BCDZ');
end
if jq==1
save('labor_QUARTERLY_RESULTS_LABOR_JQ');
end
if cmr==1
save('labor_QUARTERLY_RESULTS_LABOR_CMR');
end
if mpt==1
save('labor_QUARTERLY_RESULTS_LABOR_MPT');
end
if chol==1
save('labor_QUARTERLY_RESULTS_LABOR_CHOL');
end
else%NONLIN
  m=quantile(reg_firms,[0.16,0.5,0.84],3);
m_mis=quantile(mis,[0.16,0.5,0.84],3);%POS
m_mis1=quantile(mis1,[0.16,0.5,0.84],3);%NEG
m_mis2=quantile(mis2,[0.16,0.5,0.84],3);%ASYM
irf_diff1=zeros(20,5,500);
%POSITIVE SHOCK
for i=1:500
for j=1:5
    irf_diff1(:,j,i)=reg_firms(1,:,i)-reg_firms(j+1,:,i);
end
for j=[3:6]
    irf_diff2(:,j,i)=reg_firms(2,:,i)-reg_firms(j,:,i);
end
for j=[4:6]
    irf_diff3(:,j,i)=reg_firms(3,:,i)-reg_firms(j,:,i);
end
for j=[5:6]
    irf_diff4(:,j,i)=reg_firms(4,:,i)-reg_firms(j,:,i);
end
for j=[6:6]
    irf_diff5(:,j,i)=reg_firms(5,:,i)-reg_firms(j,:,i);
end
end
irf_diff11=quantile(irf_diff1,[0.16,0.5,0.84],3);
irf_diff22=quantile(irf_diff2,[0.16,0.5,0.84],3);
irf_diff33=quantile(irf_diff3,[0.16,0.5,0.84],3);
irf_diff44=quantile(irf_diff4,[0.16,0.5,0.84],3);
irf_diff55=quantile(irf_diff5,[0.16,0.5,0.84],3);

%NEGATIVE SHOCK
for i=1:500
for j=1:5
    irf_diff1(:,j,i)=reg_firms(1+6,:,i)-reg_firms(j+1+6,:,i);
end
for j=[3:6]
    irf_diff2(:,j,i)=reg_firms(2+6,:,i)-reg_firms(j+6,:,i);
end
for j=[4:6]
    irf_diff3(:,j,i)=reg_firms(3+6,:,i)-reg_firms(j+6,:,i);
end
for j=[5:6]
    irf_diff4(:,j,i)=reg_firms(4+6,:,i)-reg_firms(j+6,:,i);
end
for j=[6:6]
    irf_diff5(:,j,i)=reg_firms(5+6,:,i)-reg_firms(j+6,:,i);
end
end
irf_diff111=quantile(irf_diff1,[0.16,0.5,0.84],3);
irf_diff221=quantile(irf_diff2,[0.16,0.5,0.84],3);
irf_diff331=quantile(irf_diff3,[0.16,0.5,0.84],3);
irf_diff441=quantile(irf_diff4,[0.16,0.5,0.84],3);
irf_diff551=quantile(irf_diff5,[0.16,0.5,0.84],3);

%ASYMMETRY
for i=1:500
for j=1:5
    irf_diff1(:,j,i)=reg_firms(1+6+6,:,i)-reg_firms(j+1+6+6,:,i);
end
for j=[3:6]
    irf_diff2(:,j,i)=reg_firms(2+6+6,:,i)-reg_firms(j+6+6,:,i);
end
for j=[4:6]
    irf_diff3(:,j,i)=reg_firms(3+6+6,:,i)-reg_firms(j+6+6,:,i);
end
for j=[5:6]
    irf_diff4(:,j,i)=reg_firms(4+6+6,:,i)-reg_firms(j+6+6,:,i);
end
for j=[6:6]
    irf_diff5(:,j,i)=reg_firms(5+6+6,:,i)-reg_firms(j+6+6,:,i);
end
end
irf_diff1111=quantile(irf_diff1,[0.16,0.5,0.84],3);
irf_diff2211=quantile(irf_diff2,[0.16,0.5,0.84],3);
irf_diff3311=quantile(irf_diff3,[0.16,0.5,0.84],3);
irf_diff4411=quantile(irf_diff4,[0.16,0.5,0.84],3);
irf_diff5511=quantile(irf_diff5,[0.16,0.5,0.84],3);




x=1:20;w(1)=100;i=1;s=12;title2{1}='Percentage Deviation';title22{1}='P.P Deviation';
           subplot(3,3,1),plot(x,w(i)*m(1,:,2),'b-',x,w(i)*m(1,:,1),'b--',x,w(i)*m(1,:,3),'b--','LineWidth',3);
title('0-4 Employees','fontsize',s,'Color', [0,0,0.005]); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,2),plot(x,w(i)*m(2,:,2),'b-',x,w(i)*m(2,:,1),'b--',x,w(i)*m(2,:,3),'b--','LineWidth',3);
title('5-9 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,3),plot(x,w(i)*m(3,:,2),'b-',x,w(i)*m(3,:,1),'b--',x,w(i)*m(3,:,3),'b--','LineWidth',3);
title('10-19 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,4),plot(x,w(i)*m(4,:,2),'b-',x,w(i)*m(4,:,1),'b--',x,w(i)*m(4,:,3),'b--','LineWidth',3);
title('20-99 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,5),plot(x,w(i)*m(5,:,2),'b-',x,w(i)*m(5,:,1),'b--',x,w(i)*m(5,:,3),'b--','LineWidth',3);
title('100-499 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,6),plot(x,w(i)*m(6,:,2),'b-',x,w(i)*m(6,:,1),'b--',x,w(i)*m(6,:,3),'b--','LineWidth',3);
title('500+ Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,7),plot(x,w(i)*m_mis(1,:,2),'b-',x,w(i)*m_mis(1,:,1),'b--',x,w(i)*m_mis(1,:,3),'b--','LineWidth',3);
title('Labor-Misallocation-Induced TFP Response','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])

set(gcf,'position',get(0,'screensize'))   
export_fig(sprintf('BZ_FIRM_ALL_LABOR_NONLIN_POS%d.pdf',i),'-transparent');

s=11;
  subplot(5,3,1),plot(x,w(i)*irf_diff11(:,1,2),'b-',x,w(i)*irf_diff11(:,1,1),'b--',x,w(i)*irf_diff11(:,1,3),'b--','LineWidth',3);
title('0-4 Minus 5-9','fontsize',s,'Color', [0,0,0.005]); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
  subplot(5,3,2),plot(x,w(i)*irf_diff11(:,2,2),'b-',x,w(i)*irf_diff11(:,2,1),'b--',x,w(i)*irf_diff11(:,2,3),'b--','LineWidth',3);
title('0-4 Minus 10-19','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,3),plot(x,w(i)*irf_diff11(:,3,2),'b-',x,w(i)*irf_diff11(:,3,1),'b--',x,w(i)*irf_diff11(:,3,3),'b--','LineWidth',3);
title('0-4 Minus 20-99','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,4),plot(x,w(i)*irf_diff11(:,4,2),'b-',x,w(i)*irf_diff11(:,4,1),'b--',x,w(i)*irf_diff11(:,4,3),'b--','LineWidth',3);
title('0-4 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,5),plot(x,w(i)*irf_diff11(:,5,2),'b-',x,w(i)*irf_diff11(:,5,1),'b--',x,w(i)*irf_diff11(:,5,3),'b--','LineWidth',3);
title('0-4 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,6),plot(x,w(i)*irf_diff22(:,3,2),'b-',x,w(i)*irf_diff22(:,3,1),'b--',x,w(i)*irf_diff22(:,3,3),'b--','LineWidth',3);
title('5-9 Minus 10-19','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,7),plot(x,w(i)*irf_diff22(:,4,2),'b-',x,w(i)*irf_diff22(:,4,1),'b--',x,w(i)*irf_diff22(:,4,3),'b--','LineWidth',3);
title('5-9 Minus 20-99','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,8),plot(x,w(i)*irf_diff22(:,5,2),'b-',x,w(i)*irf_diff22(:,5,1),'b--',x,w(i)*irf_diff22(:,5,3),'b--','LineWidth',3);
title('5-9 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,9),plot(x,w(i)*irf_diff22(:,6,2),'b-',x,w(i)*irf_diff22(:,6,1),'b--',x,w(i)*irf_diff22(:,6,3),'b--','LineWidth',3);
title('5-9 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,10),plot(x,w(i)*irf_diff33(:,4,2),'b-',x,w(i)*irf_diff33(:,4,1),'b--',x,w(i)*irf_diff33(:,4,3),'b--','LineWidth',3);
title('10-19 Minus 20-99','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,11),plot(x,w(i)*irf_diff33(:,5,2),'b-',x,w(i)*irf_diff33(:,5,1),'b--',x,w(i)*irf_diff33(:,5,3),'b--','LineWidth',3);
title('10-19 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,12),plot(x,w(i)*irf_diff33(:,6,2),'b-',x,w(i)*irf_diff33(:,6,1),'b--',x,w(i)*irf_diff33(:,6,3),'b--','LineWidth',3);
title('10-19 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,13),plot(x,w(i)*irf_diff44(:,5,2),'b-',x,w(i)*irf_diff44(:,5,1),'b--',x,w(i)*irf_diff44(:,5,3),'b--','LineWidth',3);
title('20-99 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,14),plot(x,w(i)*irf_diff44(:,6,2),'b-',x,w(i)*irf_diff44(:,6,1),'b--',x,w(i)*irf_diff44(:,6,3),'b--','LineWidth',3);
title('20-99 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,15),plot(x,w(i)*irf_diff55(:,6,2),'b-',x,w(i)*irf_diff55(:,6,1),'b--',x,w(i)*irf_diff55(:,6,3),'b--','LineWidth',3);
title('100-499 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])

set(gcf,'position',get(0,'screensize'))   
export_fig(sprintf('BZ_FIRM_DIST_LABOR_NONLIN_POS%d.pdf',i),'-transparent');

close all

x=1:20;w(1)=100;i=1;s=12;title2{1}='Percentage Deviation';title22{1}='P.P Deviation';
           subplot(3,3,1),plot(x,w(i)*m(1+6,:,2),'b-',x,w(i)*m(1+6,:,1),'b--',x,w(i)*m(1+6,:,3),'b--','LineWidth',3);
title('0-4 Employees','fontsize',s,'Color', [0,0,0.005]); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,2),plot(x,w(i)*m(2+6,:,2),'b-',x,w(i)*m(2+6,:,1),'b--',x,w(i)*m(2+6,:,3),'b--','LineWidth',3);
title('5-9 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,3),plot(x,w(i)*m(3+6,:,2),'b-',x,w(i)*m(3+6,:,1),'b--',x,w(i)*m(3+6,:,3),'b--','LineWidth',3);
title('10-19 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,4),plot(x,w(i)*m(4+6,:,2),'b-',x,w(i)*m(4+6,:,1),'b--',x,w(i)*m(4+6,:,3),'b--','LineWidth',3);
title('20-99 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,5),plot(x,w(i)*m(5+6,:,2),'b-',x,w(i)*m(5+6,:,1),'b--',x,w(i)*m(5+6,:,3),'b--','LineWidth',3);
title('100-499 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,6),plot(x,w(i)*m(6+6,:,2),'b-',x,w(i)*m(6+6,:,1),'b--',x,w(i)*m(6+6,:,3),'b--','LineWidth',3);
title('500+ Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,7),plot(x,w(i)*m_mis1(1,:,2),'b-',x,w(i)*m_mis1(1,:,1),'b--',x,w(i)*m_mis1(1,:,3),'b--','LineWidth',3);
title('Labor-Misallocation-Induced TFP Response','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])

set(gcf,'position',get(0,'screensize'))   
export_fig(sprintf('BZ_FIRM_ALL_LABOR_NONLIN_NEG%d.pdf',i),'-transparent');

s=11;
  subplot(5,3,1),plot(x,w(i)*irf_diff111(:,1,2),'b-',x,w(i)*irf_diff111(:,1,1),'b--',x,w(i)*irf_diff111(:,1,3),'b--','LineWidth',3);
title('0-4 Minus 5-9','fontsize',s,'Color', [0,0,0.005]); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
  subplot(5,3,2),plot(x,w(i)*irf_diff111(:,2,2),'b-',x,w(i)*irf_diff111(:,2,1),'b--',x,w(i)*irf_diff111(:,2,3),'b--','LineWidth',3);
title('0-4 Minus 10-19','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,3),plot(x,w(i)*irf_diff111(:,3,2),'b-',x,w(i)*irf_diff111(:,3,1),'b--',x,w(i)*irf_diff111(:,3,3),'b--','LineWidth',3);
title('0-4 Minus 20-99','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,4),plot(x,w(i)*irf_diff111(:,4,2),'b-',x,w(i)*irf_diff111(:,4,1),'b--',x,w(i)*irf_diff111(:,4,3),'b--','LineWidth',3);
title('0-4 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,5),plot(x,w(i)*irf_diff111(:,5,2),'b-',x,w(i)*irf_diff111(:,5,1),'b--',x,w(i)*irf_diff111(:,5,3),'b--','LineWidth',3);
title('0-4 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,6),plot(x,w(i)*irf_diff221(:,3,2),'b-',x,w(i)*irf_diff221(:,3,1),'b--',x,w(i)*irf_diff221(:,3,3),'b--','LineWidth',3);
title('5-9 Minus 10-19','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,7),plot(x,w(i)*irf_diff221(:,4,2),'b-',x,w(i)*irf_diff221(:,4,1),'b--',x,w(i)*irf_diff221(:,4,3),'b--','LineWidth',3);
title('5-9 Minus 20-99','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,8),plot(x,w(i)*irf_diff221(:,5,2),'b-',x,w(i)*irf_diff221(:,5,1),'b--',x,w(i)*irf_diff221(:,5,3),'b--','LineWidth',3);
title('5-9 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,9),plot(x,w(i)*irf_diff221(:,6,2),'b-',x,w(i)*irf_diff221(:,6,1),'b--',x,w(i)*irf_diff221(:,6,3),'b--','LineWidth',3);
title('5-9 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,10),plot(x,w(i)*irf_diff331(:,4,2),'b-',x,w(i)*irf_diff331(:,4,1),'b--',x,w(i)*irf_diff331(:,4,3),'b--','LineWidth',3);
title('10-19 Minus 20-99','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,11),plot(x,w(i)*irf_diff331(:,5,2),'b-',x,w(i)*irf_diff331(:,5,1),'b--',x,w(i)*irf_diff331(:,5,3),'b--','LineWidth',3);
title('10-19 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,12),plot(x,w(i)*irf_diff331(:,6,2),'b-',x,w(i)*irf_diff331(:,6,1),'b--',x,w(i)*irf_diff331(:,6,3),'b--','LineWidth',3);
title('10-19 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,13),plot(x,w(i)*irf_diff441(:,5,2),'b-',x,w(i)*irf_diff441(:,5,1),'b--',x,w(i)*irf_diff441(:,5,3),'b--','LineWidth',3);
title('20-99 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,14),plot(x,w(i)*irf_diff441(:,6,2),'b-',x,w(i)*irf_diff441(:,6,1),'b--',x,w(i)*irf_diff441(:,6,3),'b--','LineWidth',3);
title('20-99 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,15),plot(x,w(i)*irf_diff551(:,6,2),'b-',x,w(i)*irf_diff551(:,6,1),'b--',x,w(i)*irf_diff551(:,6,3),'b--','LineWidth',3);
title('100-499 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])

set(gcf,'position',get(0,'screensize'))   
export_fig(sprintf('BZ_FIRM_DIST_LABOR_NONLIN_NEG%d.pdf',i),'-transparent');

close all


x=1:20;w(1)=100;i=1;s=12;title2{1}='Percentage Deviation';title22{1}='P.P Deviation';
           subplot(3,3,1),plot(x,w(i)*m(1+6+6,:,2),'b-',x,w(i)*m(1+6+6,:,1),'b--',x,w(i)*m(1+6+6,:,3),'b--','LineWidth',3);
title('0-4 Employees','fontsize',s,'Color', [0,0,0.005]); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,2),plot(x,w(i)*m(2+6+6,:,2),'b-',x,w(i)*m(2+6+6,:,1),'b--',x,w(i)*m(2+6+6,:,3),'b--','LineWidth',3);
title('5-9 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,3),plot(x,w(i)*m(3+6+6,:,2),'b-',x,w(i)*m(3+6+6,:,1),'b--',x,w(i)*m(3+6+6,:,3),'b--','LineWidth',3);
title('10-19 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,4),plot(x,w(i)*m(4+6+6,:,2),'b-',x,w(i)*m(4+6+6,:,1),'b--',x,w(i)*m(4+6+6,:,3),'b--','LineWidth',3);
title('20-99 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,5),plot(x,w(i)*m(5+6+6,:,2),'b-',x,w(i)*m(5+6+6,:,1),'b--',x,w(i)*m(5+6+6,:,3),'b--','LineWidth',3);
title('100-499 Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,6),plot(x,w(i)*m(6+6+6,:,2),'b-',x,w(i)*m(6+6+6,:,1),'b--',x,w(i)*m(6+6+6,:,3),'b--','LineWidth',3);
title('500+ Employees','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])
           subplot(3,3,7),plot(x,w(i)*m_mis2(1,:,2),'b-',x,w(i)*m_mis2(1,:,1),'b--',x,w(i)*m_mis2(1,:,3),'b--','LineWidth',3);
title('Labor-Misallocation-Induced TFP Response','fontsize',s); xlabel('Horizon');ylabel(title2{i},'fontsize',s);xlim([0 size(x,2)])

set(gcf,'position',get(0,'screensize'))   
export_fig(sprintf('BZ_FIRM_ALL_LABOR_NONLIN_ASYM%d.pdf',i),'-transparent');

s=11;
  subplot(5,3,1),plot(x,w(i)*irf_diff1111(:,1,2),'b-',x,w(i)*irf_diff1111(:,1,1),'b--',x,w(i)*irf_diff1111(:,1,3),'b--','LineWidth',3);
title('0-4 Minus 5-9','fontsize',s,'Color', [0,0,0.005]); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
  subplot(5,3,2),plot(x,w(i)*irf_diff1111(:,2,2),'b-',x,w(i)*irf_diff1111(:,2,1),'b--',x,w(i)*irf_diff1111(:,2,3),'b--','LineWidth',3);
title('0-4 Minus 10-19','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,3),plot(x,w(i)*irf_diff1111(:,3,2),'b-',x,w(i)*irf_diff1111(:,3,1),'b--',x,w(i)*irf_diff1111(:,3,3),'b--','LineWidth',3);
title('0-4 Minus 20-99','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,4),plot(x,w(i)*irf_diff1111(:,4,2),'b-',x,w(i)*irf_diff1111(:,4,1),'b--',x,w(i)*irf_diff1111(:,4,3),'b--','LineWidth',3);
title('0-4 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,5),plot(x,w(i)*irf_diff1111(:,5,2),'b-',x,w(i)*irf_diff1111(:,5,1),'b--',x,w(i)*irf_diff1111(:,5,3),'b--','LineWidth',3);
title('0-4 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,6),plot(x,w(i)*irf_diff2211(:,3,2),'b-',x,w(i)*irf_diff2211(:,3,1),'b--',x,w(i)*irf_diff2211(:,3,3),'b--','LineWidth',3);
title('5-9 Minus 10-19','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,7),plot(x,w(i)*irf_diff2211(:,4,2),'b-',x,w(i)*irf_diff2211(:,4,1),'b--',x,w(i)*irf_diff2211(:,4,3),'b--','LineWidth',3);
title('5-9 Minus 20-99','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,8),plot(x,w(i)*irf_diff2211(:,5,2),'b-',x,w(i)*irf_diff2211(:,5,1),'b--',x,w(i)*irf_diff2211(:,5,3),'b--','LineWidth',3);
title('5-9 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,9),plot(x,w(i)*irf_diff2211(:,6,2),'b-',x,w(i)*irf_diff2211(:,6,1),'b--',x,w(i)*irf_diff2211(:,6,3),'b--','LineWidth',3);
title('5-9 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,10),plot(x,w(i)*irf_diff3311(:,4,2),'b-',x,w(i)*irf_diff3311(:,4,1),'b--',x,w(i)*irf_diff3311(:,4,3),'b--','LineWidth',3);
title('10-19 Minus 20-99','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,11),plot(x,w(i)*irf_diff3311(:,5,2),'b-',x,w(i)*irf_diff3311(:,5,1),'b--',x,w(i)*irf_diff3311(:,5,3),'b--','LineWidth',3);
title('10-19 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,12),plot(x,w(i)*irf_diff3311(:,6,2),'b-',x,w(i)*irf_diff3311(:,6,1),'b--',x,w(i)*irf_diff3311(:,6,3),'b--','LineWidth',3);
title('10-19 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,13),plot(x,w(i)*irf_diff4411(:,5,2),'b-',x,w(i)*irf_diff4411(:,5,1),'b--',x,w(i)*irf_diff4411(:,5,3),'b--','LineWidth',3);
title('20-99 Minus 100-499','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,14),plot(x,w(i)*irf_diff4411(:,6,2),'b-',x,w(i)*irf_diff4411(:,6,1),'b--',x,w(i)*irf_diff4411(:,6,3),'b--','LineWidth',3);
title('20-99 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])
subplot(5,3,15),plot(x,w(i)*irf_diff5511(:,6,2),'b-',x,w(i)*irf_diff5511(:,6,1),'b--',x,w(i)*irf_diff5511(:,6,3),'b--','LineWidth',3);
title('100-499 Minus 500+','fontsize',s); xlabel('');ylabel(title22{i},'fontsize',s);xlim([0 size(x,2)])

set(gcf,'position',get(0,'screensize'))   
export_fig(sprintf('BZ_FIRM_DIST_LABOR_NONLIN_ASYM%d.pdf',i),'-transparent');

close all





save('labor_QUARTERLY_RESULTS_LABOR_NONLIN');
end